/**
 * Created by Administrator on 2016/7/15.
 */
//显示日记本列表
var session_id = sessionStorage.session_id;
$(document).ready(function(){
    //获取日记本列表
    var u_id = sessionStorage.u_id;
    if(u_id){
        var user_token =  sessionStorage.user_token;
        $.post(commonval+"/note_book_list", {
            user_token:user_token,
            device:"wap",
            u_id : u_id,
            session_id:session_id
        }, function (data) {
            if(data.status == 1){
                if(data.data == ''){
                    $(".consult").css("display","block");
                    $(".Tips button").click(function(){
                        location.href="doctorList.html";
                    })
                }else{
                    $(".mainPart").css("display","block");
                    var dairyBook = new Vue({
                        el: '#mainPart',
                        data: {
                            items: data.data
                        }
                    });
                    //写日记跳转传值
                    $("button.button").click(function(e){
                        var book_id = $(this).parents(".mainPart").children("section.extra").children("p.book_id").text();
                        var order_num = $(this).parents(".mainPart").children("section.extra").children("p.order_num").text();
                        location.href="writeDairy.html?order_num="+order_num;
                        sessionStorage.book_id = book_id;
                        e.stopPropagation();
                    })
                    //日记本跳转传值
                    $(".mainPart").click(function(e){
                        var order_num = $(this).children("section.extra").children("p.order_num").text()
                        var book_id = $(this).children("section.extra").children("p.book_id").text();
                        location.href="hairDairy.html?order_num="+order_num;
                        sessionStorage.book_id = book_id;
                    })
                }
            }else{
                createWindow("获取日记列表失败");
                function createWindow(msg) {
                    var window =$("<section class='showMsg'></section>");
                    var show = "<p>"+msg+"</p>";
                    window.append(show);
                    $("body").append(window);
                    setTimeout("$('.showMsg').remove()",3000);
                }
            }
        });
    }else{
        $(".login").css("display","block");
        $(".Tips button").click(function(){
            location.href="register.html?jump=6";
        })

    }
});
